home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_d / isamexpt.zip / WNTISAM2.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-05  |  20KB  |  600 lines

  1. unit Wntisam2;
  2.  
  3. interface
  4. uses WinTypes, Classes, Graphics, Forms;
  5. {$I DEFINE.PAS}
  6. function Erzeuge_EditorForm(const FormIdent: string;
  7.                             RecList: TStringList;
  8.                             Label_Neben_Input: Boolean;
  9.                             InputLen_Fest: Boolean;
  10.                             LFont, EFont: TFont;
  11.                             Sprache: Integer): TForm;
  12.  
  13. implementation
  14.  
  15. Uses WinProcs, SysUtils, Controls, ExtCtrls, Proxies,
  16.      Db, WntIsam4, StdCtrls, Buttons,
  17.      {$IFDEF NEWINPUTS}
  18.      NumCtrl, DateEdit,
  19.      {$ENDIF}
  20.      IsamTabl;
  21.  
  22. function Erzeuge_EditorForm(const FormIdent: string;
  23.                             RecList: TStringList;
  24.                             Label_Neben_Input: Boolean;
  25.                             InputLen_Fest: Boolean;
  26.                             LFont, EFont: TFont;
  27.                             Sprache: Integer): TForm;
  28. var
  29.   BtnPos   : TPoint;
  30.   Method,KeyMethod: TMethod;
  31.   MP,UP,UP1,UP2,UP3: TPanel;
  32.   SP       : TSpeedButton;
  33.   Tbl      : TIsamTable;
  34.   dx,W,i,Ty,G : Integer;
  35.   xDecimals : Integer;
  36.   SLab     : TLabel;
  37.   {$IFDEF NEWINPUTS}
  38.   SInp     : TStrEdit;
  39.   DInp     : TDateEdit;
  40.   NInp     : TNumEdit;
  41.   {$ELSE}
  42.   SInp     : TEdit;
  43.   PInp     : TEdit;
  44.   NInp     : TEdit;
  45.   {$ENDIF}
  46.   MInp     : TMemo;
  47.   RInp     : TRadioGroup;
  48.   Tm       : TTimer;
  49.   FieldName,FeldName,SStr,AStr,MStr: String;
  50.   Len,Arr1,Arr2,A    : Integer;
  51.   FieldDataType      : TFieldType;
  52. begin
  53.   Result := TProxyForm.CreateAs('T' + FormIdent);
  54.   with Result do begin
  55.     BorderStyle := bsDialog;
  56.     Left:= 100;
  57.     Top:= 101;
  58.     Width := 400;
  59.     Height := 282;
  60.     Position := poScreenCenter;
  61.     Name := FormIdent;
  62.     Caption := FormIdent;
  63.     KeyPreview:= True;
  64.     AutoScroll  := True;
  65.     Method.Code := TProxyForm(Result).CreateMethod('FormCreate');
  66.     Method.Data := Result;
  67.     OnCreate    := TNotifyEvent(Method);
  68.     Method.Code := TProxyForm(Result).CreateMethod('FormDestroy');
  69.     Method.Data := Result;
  70.     OnDestroy   := TNotifyEvent(Method);
  71.     KeyMethod.Code:= TProxyForm(Result).CreateMethod('FormKeyPress');
  72.     KeyMethod.Data:= Result;
  73.     OnKeyPress:= TKeyPressEvent(KeyMethod);
  74.     with Font do begin
  75.       Color := clBlack;
  76.       Height:= -11;
  77.       Name := 'Arial';
  78.       Size := 8;
  79.       Style:= [fsBold];
  80.     end;
  81.  
  82.     MP:= TPanel.Create(Result);
  83.     with MP do begin
  84.       Parent := Result;
  85.       Name := 'Panel1';
  86.       Align := alTop;
  87.       ShowHint:= True;
  88.       Caption:= '';
  89.     end;
  90.  
  91.     Sp:= TSpeedButton.Create(Result);
  92.     with SP do begin
  93.       Parent:= MP;
  94.       Left:= 10;
  95.       Top := 8;
  96.       Width := 25;
  97.       Height := 25;
  98.       if Sprache = 1 then Hint:= 'Back'
  99.       else Hint := 'Zurⁿck';
  100.       Name := 'RueckBttn';
  101.       Glyph.Handle:= LoadBitmap(HInstance,'IS_RUECK');
  102.       Method.Code := TProxyForm(Result).CreateMethod('RueckBttnClick');
  103.       Method.Data := Result;
  104.       Sp.OnClick := TNotifyEvent(Method);
  105.     end;
  106.  
  107.     Sp:= TSpeedButton.Create(Result);
  108.     with SP do begin
  109.       Parent:= MP;
  110.       Left:= 35;
  111.       Top := 8;
  112.       Width := 25;
  113.       Height := 25;
  114.       if Sprache = 1 then Hint:= 'forward'
  115.       else Hint := 'VorwΣrts';
  116.       Name := 'VorBttn';
  117.       Glyph.Handle:= LoadBitmap(HInstance,'IS_VOR');
  118.       Method.Code := TProxyForm(Result).CreateMethod('VorBttnClick');
  119.       Method.Data := Result;
  120.       Sp.OnClick := TNotifyEvent(Method);
  121.     end;
  122.  
  123.     Sp:= TSpeedButton.Create(Result);
  124.     with SP do begin
  125.       Parent:= MP;
  126.       Left:= 60;
  127.       Top := 8;
  128.       Width := 25;
  129.       Height := 25;
  130.       if Sprache = 1 then Hint:= 'Search'
  131.       else Hint := 'Suchen';
  132.       Name := 'SuchBttn';
  133.       Glyph.Handle:= LoadBitmap(HInstance,'IS_SUCH');
  134.       Method.Code := TProxyForm(Result).CreateMethod('SuchBttnClick');
  135.       Method.Data := Result;
  136.       Sp.OnClick := TNotifyEvent(Method);
  137.     end;
  138.  
  139.     Sp:= TSpeedButton.Create(Result);
  140.     with SP do begin
  141.       Parent:= MP;
  142.       Left:= 85;
  143.       Top := 8;
  144.       Width := 25;
  145.       Height := 25;
  146.       if Sprache = 1 then Hint:= 'Sort order'
  147.       else Hint := 'Sortierordnung';
  148.       Name := 'KeyBttn';
  149.       Glyph.Handle:= LoadBitmap(HInstance,'IS_KEY');
  150.       Method.Code := TProxyForm(Result).CreateMethod('KeyBttnClick');
  151.       Method.Data := Result;
  152.       Sp.OnClick := TNotifyEvent(Method);
  153.     end;
  154.  
  155.     Sp:= TSpeedButton.Create(Result);
  156.     with SP do begin
  157.       Parent:= MP;
  158.       Left:= 110;
  159.       Top := 8;
  160.       Width := 25;
  161.       Height := 25;
  162.       if Sprache = 1 then Hint:= 'clear'
  163.       else Hint := 'Leeren';
  164.       Name := 'NeuBttn';
  165.       Glyph.Handle:= LoadBitmap(HInstance,'IS_NEU');
  166.       Method.Code := TProxyForm(Result).CreateMethod('NeuBttnClick');
  167.       Method.Data := Result;
  168.       Sp.OnClick := TNotifyEvent(Method);
  169.     end;
  170.  
  171.     Sp:= TSpeedButton.Create(Result);
  172.     with SP do begin
  173.       Parent:= MP;
  174.       Left:= 135;
  175.       Top := 8;
  176.       Width := 25;
  177.       Height := 25;
  178.       if Sprache = 1 then Hint:= 'save new record'
  179.       else Hint := 'Anlegen';
  180.       Name := 'AnlegBttn';
  181.       Glyph.Handle:= LoadBitmap(HInstance,'IS_ANLEGEN');
  182.       Method.Code := TProxyForm(Result).CreateMethod('AnlegBttnClick');
  183.       Method.Data := Result;
  184.       Sp.OnClick := TNotifyEvent(Method);
  185.     end;
  186.  
  187.     Sp:= TSpeedButton.Create(Result);
  188.     with SP do begin
  189.       Parent:= MP;
  190.       Left:= 160;
  191.       Top := 8;
  192.       Width := 25;
  193.       Height := 25;
  194.       if Sprache = 1 then Hint:= 'save changed record'
  195.       else Hint := '─ndern';
  196.       Name := 'AendernBttn';
  197.       Glyph.Handle:= LoadBitmap(HInstance,'IS_AENDERN');
  198.       Method.Code := TProxyForm(Result).CreateMethod('AendernBttnClick');
  199.       Method.Data := Result;
  200.       Sp.OnClick := TNotifyEvent(Method);
  201.     end;
  202.  
  203.     Sp:= TSpeedButton.Create(Result);
  204.     with SP do begin
  205.       Parent:= MP;
  206.       Left:= 185;
  207.       Top := 8;
  208.       Width := 25;
  209.       Height := 25;
  210.       if Sprache = 1 then Hint:= 'delete record'
  211.       else Hint := 'L÷schen';
  212.       Name := 'LoeschBttn';
  213.       Glyph.Handle:= LoadBitmap(HInstance,'IS_LOESCHEN');
  214.       Method.Code := TProxyForm(Result).CreateMethod('LoeschBttnClick');
  215.       Method.Data := Result;
  216.       Sp.OnClick := TNotifyEvent(Method);
  217.     end;
  218.  
  219.     Sp:= TSpeedButton.Create(Result);
  220.     with SP do begin
  221.       Parent:= MP;
  222.       Left:= 215;
  223.       Top := 8;
  224.       Width := 25;
  225.       Height := 25;
  226.       Hint := 'Ok';
  227.       Name := 'OkBttn';
  228.       Glyph.Handle:= LoadBitmap(HInstance,'IS_OK');
  229.       Method.Code := TProxyForm(Result).CreateMethod('OkBttnClick');
  230.       Method.Data := Result;
  231.       Sp.OnClick := TNotifyEvent(Method);
  232.     end;
  233.  
  234.     Sp:= TSpeedButton.Create(Result);
  235.     with SP do begin
  236.       Parent:= MP;
  237.       Left:= 358;
  238.       Top := 8;
  239.       Width := 25;
  240.       Height := 25;
  241.       if Sprache = 1 then Hint:= 'End'
  242.       else Hint := 'Ende';
  243.       Name := 'AbbruchBttn';
  244.       Glyph.Handle:= LoadBitmap(HInstance,'IS_ENDE');
  245.       Method.Code := TProxyForm(Result).CreateMethod('AbbruchBttnClick');
  246.       Method.Data := Result;
  247.       Sp.OnClick := TNotifyEvent(Method);
  248.     end;
  249.  
  250.     UP:= TPanel.Create(Result);
  251.     with UP do begin
  252.       Parent := Result;
  253.       Name := 'Panel2';
  254.       Align := alBottom;
  255.       BevelInner:= bvLowered;
  256.       Height:= 27;
  257.       ShowHint:= False;
  258.       Caption:= '';
  259.     end;
  260.  
  261.     UP1:= TPanel.Create(Result);
  262.     With UP1 do begin
  263.       Parent:= UP;
  264.       Left  := 308;
  265.       Top   := 2;
  266.       Width := 108;
  267.       Height:= 23;
  268.       Align := alRight;
  269.       BevelOuter := bvLowered;
  270.       Font.Color := clBlack;
  271.       Font.Height := -11;
  272.       Font.Name := 'Arial';
  273.       Font.Style := [];
  274.       Name:= 'ZeitPanel';
  275.       Caption:= '';
  276.     end;
  277.  
  278.     UP3:= TPanel.Create(Result);
  279.     with UP3 do begin
  280.       Parent:= UP;
  281.       Left  := 2;
  282.       Top   := 2;
  283.       Width := 186;
  284.       Height:= 23;
  285.       Align := alClient;
  286.       ShowHint:= True;
  287.       BevelInner := bvLowered;
  288.       BevelOuter := bvNone;
  289.       Font.Color := clBlack;
  290.       Font.Height := -11;
  291.       Font.Name   := 'Arial';
  292.       Font.Style  := [];
  293.       Name:= 'HintPanel';
  294.       Caption:= '';
  295.     end;
  296.  
  297.     Tm:= TTimer.Create(Result);
  298.     With Tm do begin
  299.       Interval:= 1000;
  300.       Name:= FormIdent+'Timer';
  301.       Method.Code := TProxyForm(Result).CreateMethod(FormIdent+'TimerTimer');
  302.       Method.Data := Result;
  303.       Tm.OnTimer := TNotifyEvent(Method);
  304.     end;
  305.  
  306.     Tbl:= TIsamTable.Create(Result);
  307.     with Tbl do begin
  308.       Name:= FormIdent+'TABLE';
  309.       TableName   := '';
  310.     end;
  311.  
  312.     if RecList.Count > 0 then begin
  313.       Ty:= 52;
  314.       For i:= 0 to RecList.Count - 1 do begin
  315.         SStr:= RecList[i];
  316.         if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0)
  317.         and (Pos('IGNORE',Uppercase(SStr)) = 0) then begin
  318.           G:= GetFieldTypEditor(SStr,FeldName,FieldDataType,Len,Arr1,Arr2,xDecimals);
  319.           FieldName:= FeldName;
  320.           if Label_Neben_Input = False then Inc(Ty,18);
  321.           if InputLen_Fest then W:= 130 else W:= 8 * (Len - 1);
  322.           if W < 30 then W:= 30;
  323.           if W > 255 then W:= 255;
  324.           For a:= Arr1 to Arr2 do begin
  325.             if Arr1 <> Arr2 then begin
  326.               Str(A,AStr);
  327.               FieldName:= FeldName+AStr;
  328.             end;
  329.             {$IFDEF NEWINPUTS}
  330.             Case G of
  331.               1: begin
  332.                    DInp:= TDateEdit.Create(Result);
  333.                    with DInp do begin
  334.                      Name:= FieldName + 'Input';
  335.                      Parent:= Result;
  336.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  337.                      Top   := Ty;
  338.                      Width := 80;
  339.                      Height := 21;
  340.                      Cursor := crIBeam;
  341.                      Font.Color := EFont.Color;
  342.                      Font.Height := EFont.Height;
  343.                      Font.Name := EFont.Name;
  344.                      Font.Style := EFont.Style;
  345.                      ParentColor := False;
  346.                      TabStop := True;
  347.                      if FieldDataType = ftTime then begin
  348.                        MaxLength:= 5;
  349.                      end
  350.                      else begin
  351.                        MaxLength:= 10;
  352.                      end;
  353.                    end;
  354.                  end;
  355.               2: begin
  356.                    NInp:= TNumEdit.Create(Result);
  357.                    with NInp do begin
  358.                      Name:= FieldName + 'Input';
  359.                      Parent:= Result;
  360.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  361.                      Top   := Ty;
  362.                      Width := W;
  363.                      Height := 21;
  364.                      Font.Color := EFont.Color;
  365.                      Font.Height := EFont.Height;
  366.                      Font.Name := EFont.Name;
  367.                      Font.Style := EFont.Style;
  368.                      ParentColor := False;
  369.                      TabStop := True;
  370.                      NumericType:= ntGeneral;
  371.                      Case FieldDataType of
  372.                        ftInteger,
  373.                        ftBytes   : begin
  374.                                      Decimals:= 0;
  375.                                      Masks.PositiveMask:= '#0';
  376.                                    end;
  377.                        ftSmallInt: begin
  378.                                      Decimals:= 0;
  379.                                      Masks.PositiveMask:= '#0';
  380.                                    end;
  381.                        ftWord    : begin
  382.                                      Decimals:= 0;
  383.                                      Masks.PositiveMask:= '#0';
  384.                                    end;
  385.                        else begin
  386.                          Decimals:= xDecimals;
  387.                          if xDecimals < 2 then MStr:= '0.0'
  388.                          else begin
  389.                            MStr:= '0.#';
  390.                            For dx:= 2 to xDecimals do MStr:= MStr + '0';
  391.                          end;
  392.                          Masks.PositiveMask:= MStr;
  393.                        end;
  394.                      end;
  395.                    end;
  396.                  end;
  397.               3: begin
  398.                    MInp:= TMemo.Create(Result);
  399.                    with MInp do begin
  400.                      Name:= FieldName + 'Input';
  401.                      Parent:= Result;
  402.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  403.                      Top   := Ty;
  404.                      Width := 130;
  405.                      Height := 89;
  406.                      Font.Color := EFont.Color;
  407.                      Font.Height := EFont.Height;
  408.                      Font.Name := Efont.Name;
  409.                      Font.Style := EFont.Style;
  410.                      ParentColor := False;
  411.                      Scrollbars:= ssBoth;
  412.                      TabStop := True;
  413.                    end;
  414.                  end;
  415.               4: begin
  416.                    RInp:= TRadioGroup.Create(Result);
  417.                    with RInp do begin
  418.                      Name:= FieldName+'Input';
  419.                      Parent:= Result;
  420.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  421.                      Top   := Ty;
  422.                      Width := 133;
  423.                      Height := 37;
  424.                      Font.Color := EFont.Color;
  425.                      Font.Height := EFont.Height;
  426.                      Font.Name := Efont.Name;
  427.                      Font.Style := EFont.Style;
  428.                      ParentColor := False;
  429.                      TabStop := True;
  430.                      Columns:= 2;
  431.                      Caption:= '';
  432.                      if Sprache = 1 then begin
  433.                        Items.Add('No');
  434.                        Items.Add('Yes');
  435.                      end
  436.                      else begin
  437.                        Items.Add('Nein');
  438.                        Items.Add('Ja');
  439.                      end;
  440.                      ItemIndex:= -1;
  441.                    end;
  442.                  end;
  443.               else begin
  444.                    SInp:= TStrEdit.Create(Result);
  445.                    with SInp do begin
  446.                      Name:= FieldName + 'Input';
  447.                      Parent:= Result;
  448.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  449.                      Top   := Ty;
  450.                      Width := W;
  451.                      Height := 21;
  452.                      Font.Color := EFont.Color;
  453.                      Font.Height := EFont.Height;
  454.                      Font.Name := EFont.Name;
  455.                      Font.Style := EFont.Style;
  456.                      ParentColor := False;
  457.                      if Pos('{UPCASE}',Uppercase(SStr)) > 0 then CharCase:= ecUppercase;
  458.                      MaxLength:= Len;
  459.                      TabStop := True;
  460.                    end;
  461.                  end;
  462.             end;
  463.             {$ELSE}
  464.             Case G of
  465.               1: begin
  466.                    PInp:= TEdit.Create(Result);
  467.                    with PInp do begin
  468.                      Name:= FieldName + 'Input';
  469.                      Parent:= Result;
  470.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  471.                      Top   := Ty;
  472.                      Width := W;
  473.                      Height := 21;
  474.                      Cursor := crIBeam;
  475.                      Font.Color := EFont.Color;
  476.                      Font.Height := EFont.Height;
  477.                      Font.Name := EFont.Name;
  478.                      Font.Style := EFont.Style;
  479.                      ParentColor := False;
  480.                      TabStop := True;
  481.                      if FieldDataType = ftTime then begin
  482.                        MaxLength:= 5;
  483.                      end
  484.                      else begin
  485.                        MaxLength:= 10;
  486.                      end;
  487.                    end;
  488.                  end;
  489.               2: begin
  490.                    SInp:= TEdit.Create(Result);
  491.                    with SInp do begin
  492.                      Name:= FieldName + 'Input';
  493.                      Parent:= Result;
  494.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  495.                      Top   := Ty;
  496.                      Width := W;
  497.                      Height := 21;
  498.                      Cursor := crIBeam;
  499.                      Font.Color := EFont.Color;
  500.                      Font.Height := EFont.Height;
  501.                      Font.Name := EFont.Name;
  502.                      Font.Style := EFont.Style;
  503.                      ParentColor := False;
  504.                      TabStop := True;
  505.                    end;
  506.                  end;
  507.               3: begin
  508.                    MInp:= TMemo.Create(Result);
  509.                    with MInp do begin
  510.                      Name:= FieldName + 'Input';
  511.                      Parent:= Result;
  512.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  513.                      Top   := Ty;
  514.                      Width := 130;
  515.                      Height := 89;
  516.                      Font.Color := EFont.Color;
  517.                      Font.Height := EFont.Height;
  518.                      Font.Name := Efont.Name;
  519.                      Font.Style := EFont.Style;
  520.                      ParentColor := False;
  521.                      ScrollBars:= ssBoth;
  522.                      TabStop := True;
  523.                    end;
  524.                  end;
  525.               4: begin
  526.                    RInp:= TRadioGroup.Create(Result);
  527.                    with RInp do begin
  528.                      Name:= FieldName+'Input';
  529.                      Parent:= Result;
  530.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  531.                      Top   := Ty;
  532.                      Width := 133;
  533.                      Height := 37;
  534.                      Font.Color := EFont.Color;
  535.                      Font.Height := EFont.Height;
  536.                      Font.Name := Efont.Name;
  537.                      Font.Style := EFont.Style;
  538.                      ParentColor := False;
  539.                      TabStop := True;
  540.                      Columns:= 2;
  541.                      Caption:= '';
  542.                      if Sprache = 1 then begin
  543.                        Items.Add('No');
  544.                        Items.Add('Yes');
  545.                      end
  546.                      else begin
  547.                        Items.Add('Nein');
  548.                        Items.Add('Ja');
  549.                      end;
  550.                      ItemIndex:= -1;
  551.                    end;
  552.                  end;
  553.               else begin
  554.                    SInp:= TEdit.Create(Result);
  555.                    with SInp do begin
  556.                      Name:= FieldName + 'Input';
  557.                      Parent:= Result;
  558.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  559.                      Top   := Ty;
  560.                      Width := W;
  561.                      Height := 21;
  562.                      Cursor := crIBeam;
  563.                      Font.Color := EFont.Color;
  564.                      Font.Height := EFont.Height;
  565.                      Font.Name := EFont.Name;
  566.                      Font.Style := EFont.Style;
  567.                      ParentColor := False;
  568.                      TabStop := True;
  569.                      if Pos('{UPCASE}',Uppercase(SStr)) > 0 then CharCase:= ecUppercase;
  570.                      MaxLength:= Len;
  571.                    end;
  572.                  end;
  573.              end;
  574.             {$ENDIF}
  575.             if Label_Neben_Input = False then Dec(Ty,18);
  576.             SLab:= TLabel.Create(Result);
  577.             With SLab do begin
  578.               Name:= FieldName+'Label';
  579.               Parent:= Result;
  580.               Caption:= FieldName;
  581.               Left:= 20;
  582.               Top:= Ty + 2;
  583.               Font.Color := LFont.Color;
  584.               Font.Height := LFont.Height;
  585.               Font.Name := LFont.Name;
  586.               Font.Style := LFont.Style;
  587.             end;
  588.             Ty:= Ty+24;
  589.             if Label_Neben_Input = False then Inc(Ty,20);
  590.             if G = 3 then Ty:= Ty + 68;
  591.             if G = 4 then Ty:= Ty + 20;
  592.           end; {for arr1 to arr2}
  593.         end;
  594.       end;
  595.     end;
  596.   end;
  597. end;
  598.  
  599. end.
  600.